package com.czy.owner.adapter;

import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.TextView;

import com.czy.owner.R;
import com.czy.owner.entity.WheelAttrModel;
import com.easyrecycleview.adapter.BaseViewHolder;
import com.easyrecycleview.adapter.RecyclerArrayAdapter;

/**
 * Created by Raven on 2018/1/10.
 */

public class WheelFilterChildAdapter extends RecyclerArrayAdapter<WheelAttrModel> {

    private Context context;

    public WheelFilterChildAdapter(Context context) {
        super(context);
        this.context = context;
    }


    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        return new ClassifyHolder(parent);
    }

    class ClassifyHolder extends BaseViewHolder<WheelAttrModel> {
        private CheckBox cbClassify;
        private TextView tvClassifyName;

        public ClassifyHolder(ViewGroup parent) {
            super(parent, R.layout.item_wheel_filter_child_layout);
            cbClassify = $(R.id.cb_classify);
            tvClassifyName = $(R.id.tv_classify_name);
        }

        @Override
        public void setData(final WheelAttrModel model) {
            super.setData(model);
            tvClassifyName.setText(model.getName());
            cbClassify.setChecked(model.isChoosed());
            tvClassifyName.setTextColor(model.isChoosed()
                            ? ContextCompat.getColor(context,R.color.appThemeColor)
                            : ContextCompat.getColor(context,R.color.black));

        }
    }
}
